<?php
/* @var $this RosterController */

$this->pageTitle=Yii::app()->name . ' - Management';
$this->breadcrumbs=array(
	'Management'=>array('/site/management/'),
	'Roster Control',
);
?>
<h1>Roster Control</h1>

<div id='top-wrapper'>

<table>
  <td>
	<div id='leftVisor' style='width:515px;'>
	<!--left Visor-->
	
		<?php //$this->renderPartial('_etherpad'); ?>
		<br>
		<br>
		<br>
		<br><center>
		<H2><SPAN style="color:blue">ETHERPAD GOES HERE... </span></H2>
	</div>
	
  </td>
  <td>
	<div id='calendar' style=''>
	<center>
	<?php
		$now = new DateTime("now");
		$now->setTimeZone(new DateTimeZone("America/Costa_Rica"));
		
		$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			//'model' => $model,
			//'attribute' => 'day_requested',
			'name'=> 'dateSelector',
			'themeUrl' => Yii::app()->baseUrl . '/css/jui',
			'theme' => 'start',
			'cssFile' => 'jquery-ui-1.10.3.custom.css',		
			'flat'=>true,
			 'options' => array(
					'showOn' => 'both',             // also opens with a button
					'dateFormat' => 'yy-mm-dd',     // format of "2012-12-25"
					'showOtherMonths' => true,      // show dates in other months
					//'selectOtherMonths' => true,    // can select dates in other months
					//'changeYear' => true,           // can change year
					//'changeMonth' => true,          // can change month
					'yearRange' => '2013:2020',     // range of year
					//'minDate' => $now->format('Y-m-d'),      // minimum date
					'maxDate' => '2020-12-31',      // maximum date
					'showButtonPanel' => true,      // show button panel
					/*
					'onSelect' => 'js: function(dateText, inst){
								loadData(dateText);
							}', 	
					//'onSelect'=>'js:function(dateText, inst){alert(dateText);}',
				   'onSelect'=> 'js: function(dateText, inst) {'.
									 CHtml::ajax(array('type'=>'POST','datatype'=>'html','url'=>array('roster/ajaxScheduleChange'),
												'data'=>array('date'=>'js: dateText ;}'))
										 )
					'onSelect	'=> 'js:function(dateText, inst) {'.
										CHtml::ajax(
											array(
												'type'=>'POST',
												'url'=>Yii::app()->createUrl('roster/ajaxScheduleChange'),
												'data'=>  array('date'=>'js: $(\'#dateSelector\').val()'),              //'$(this).val()',
												'update'=>'#leftVisor'
												)
												), 
					*/
					'options'=>"js:{ onSelect:function(dateText,inst){" .
																	   CHtml::ajax(
																			array(
																				'type'=>'POST',
																				'url'=>Yii::app()->createUrl('roster/ajaxScheduleChange'),
																				'data'=>  array('date'=>'js: $(\'#dateSelector\').val()'),              //'$(this).val()',
																				'update'=>'#leftVisor',
																				)
																			)
																		."},
																	   }",
				),
			'htmlOptions' => array(
				'size' => '10',        
				'maxlength' => '10',  
				'id'=>'dateSelector',
			),
		));				
							
								
	?>
	</center>
	</div>
  </td>
</table>
</div>
<!--VISOR -->

<?php

//echo '<a href="http://stackoverflow.com/questions/3066171/can-i-refresh-a-yii-cgridview-from-js">Link Reminder</a>';	
//echo "<br><br>";

		

	
//$dateArray = explode('-',$date);
$dateObject = new DateTime('NOW');
$dateObject->setTimeZone(new DateTimeZone("America/Costa_Rica"));
//$dateObject->setDate('2013','11','10');
$timestamp = strtotime($dateObject->format('Y-m-d'));
$currentWeek  = $dateObject->format('W');
$year = $dateObject->format('Y');
//echo "week = $week and year = $year";
?>

<div id="gridVisor">

<?php
Yii::app()->session['currentWeek']= $currentWeek;
Yii::app()->session['year']= $year;

$this->renderPartial('_rosterGridView',
					 null,
					 false,
					 true
					); 
?>		
		
</div>

